<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>前锋图书馆</title>
	<link rel="stylesheet" type="text/css" href="/css/searchinfo.css">
	<link rel="stylesheet" type="text/css" href="/css/base.css" />
	<style type="text/css">
		.page_control_container{margin-top: 140px;}
		.pagination{width: 1250px;padding-top: 30px !important;margin:0 auto;padding-left: 40%;}

		.headerWrap{width: 100%;height: 33px;background-color: #F7F7F7;}
		.header{width: 1250px;height: 100%;margin: 0 auto;}
		.logoimg{float: left;padding-top: 7px;}
		.logoimg i{float: left;width: 18px;height: 18px;margin-right: 4px;background-position: 0 0;}
		.sprite{background-image: url("/img/index.png");}
		i{display: block;}
		.headerright{float: right;margin-right: 20px;}
		.headercon{float: left;padding: 6px 20px 0px;font-size: 15px;cursor: pointer;}
		.headercon:hover{color: #D61A0B;}
		.headerright li{display: inline-block!important;}
		.navWrap{width: 100%;height: 50px;background-color: #fff;border-bottom: 1px solid #E7E7E7;}
		.nav{width: 1250px;height: 100%;margin: 0 auto;line-height: 50px;}
		.navli{float: left;margin-right: 50px;}
		.navli i{width: 100%;}
		.navlicon{font-size: 15px;color: #D61A0B;}
		/*.navli:hover{border-bottom: 2px solid #D61A0B;cursor: pointer;}
		.navlicon:hover{color: #D61A0B;cursor: pointer;}*/
    	.shownav{border-bottom: 2px solid #D61A0B;}
	</style>
</head>
<body>
	<div class="big">
	<!-- 头部 -->
  		<!-- title部分 -->
		<div class="title">
			<input type="hidden" value="{$bname}" id="bname">
			<div class="headerWrap">
				<div class="header">
					<div class="logoimg">
						<i class="sprite"></i>
						<a href="/index/index/index"><span class="headerLogoCon">前锋图书馆</span></a>
					</div>
					<div class="headerright">
						<div class="headercon">您好！{$uname|default='请登录'}</div>
						<!-- <div class="headercon applyrule">借阅规则</div> -->
						<a href="/index/personalcenter/index"><div class="headercon">个人中心</div></a>
						<a href="/index/index/logout"><div class="headercon">退出登录</div></a>
					</div>
				</div>
			</div>
			<div class="navWrap">
				<div class="nav">
					<div class="navli shownav">
						<div class="navlicon shownavli">搜索结果</div>
						<!-- <i class="navline"></i> -->
					</div>
					
				</div>
			</div>
		</div>
		
		<!-- list部分 -->
		<div class="list">
			
			<div class="shangyan">
				<!-- <div class="shang_title">
					<div class="librarybooks contentTitle checked"><span class="contentTiltleinfo">搜索结果</span></div>
				</div> -->
				<div class="shang_content">
					<div class="content">
					</div>
				</div>
				<div class="page_control_container">
					<div class="page_control">
						<div class="pagination"></div>
					</div>
				</div>
		</div>


		<!-- 底部 -->
		<div class="floor">
			<div class="floor_min">
				<div class="floor_min_bottom">
					<span style="text-align: center;">&copy;前锋图书管理系统</span>
				</div>
			</div>
		</div>
	</div>
</body>
<script src="/js/jquery.js"></script>
<script src="/js/layer/layer.js"></script>
<script src="/js/jquery.paging.js"></script>
<script type="text/javascript">
	$(function(){
		
		

var bookName = $("#bname").val();

	$('.pagination').paging({
	    total: '',
	    currentPage: '',
	    showPage: 5,        //显示的页数
	    animation: false,
	    showJump: false,
	    ajaxSubmitType: 'post',
	    simpleType: 1,
	    url: '/index/Searchinfo/pagesearch/bname/'+bookName,
	    idParameter: "page",
	    ajaxData: {'pageType': 1},
	    beforeAjaxSubmit: function () {
	        PageAPI.AddAjaxData({"pageSize": $(".pageSize").val()});
	    },
	    ajaxSubmitBack: function (data) {
	        $('.content').empty();
	        var orderinfo = data.data;
	        console.log(orderinfo);
	        if(orderinfo=='' ||orderinfo==undefined){
	            $(".content").html(' <h2 style="text-align: center;padding-top:120px;height: 166px;color: red; background-color: #fff;">暂无数据</h2>');
	            $(".pagination").hide();
	        }else{
	            $(".pagination").show();
	            var infohtml="";
	            $(orderinfo).each(function(i,val){ 
	        		infohtml+='<div class="contents">';
			        infohtml+='<div class="booksWrap1">';
			        if (val.img&&val.img!='') {
				        infohtml+='<div class="booksImg"><img src="'+val.img+'" class="bookImg"></div>';
				    }else{
				        infohtml+='<div class="booksImg"><img src="/img/replace.jpg" class="bookImg"></div>';
				    }
			        infohtml+='<div class="booksName1">';
			        if (val.bname&&val.bname!='') {
			        	infohtml+='<span class="bookNameinfo1" title="《'+val.bname+'》">《'+val.bname+'》</span></div>';
			        }else{
			        	infohtml+='<span class="bookNameinfo1">暂无书名</span></div>';
			        }
			        infohtml+='<div class="booksPeople">';
			        if (val.uname&&val.uname!='') {
			        	infohtml+='<span class="booksPeopleinfo">借阅人：'+val.uname+'</span></div>'; 
			        }else{
			        	infohtml+='<span class="bookNameinfo1">借阅人：暂无</span></div>';
			        }
					infohtml+='<div class="booksTime">';
					if (val.booktime&&val.booktime!='') {
			        	infohtml+='<span class="booksTimeinfo">借阅时间：'+val.booktime+'-'+val.expectedReturnTime+'</span></div>';
			        }else{
			        	infohtml+='<span class="booksTimeinfo">借阅时间：暂无</span></div>';
			        }
			        if(val.overtime&&val.overtime!=0){
			        	infohtml+='<div class="booksTime2">'; 
						infohtml+='<span class="booksPeopleinfo2">逾期时间：'+val.overtime+'天</span></div>'; 
			        }else{
			        	infohtml+='<div class="booksTime2">'; 
						infohtml+='<span class="booksPeopleinfo2">逾期时间：暂无</span></div>'; 
			        }
			        if(val.apply==1){
				        infohtml+='<div class="applysBtn">';
				        infohtml+='<span class="applysBtninfo"><input type="hidden" class="bookid" value="'+val.id+'">已申请(点击取消)</span></div>';
				    }else if(val.apply==0){
				        infohtml+='<div class="applyBtn">';
				        infohtml+='<span class="applyBtninfo"><input type="hidden" class="bookid" value="'+val.id+'">申请借阅</span></div>';
				    }else if(val.power==1&&val.states!=6){
			        	infohtml+='<div class="applyssBtn1">';
			        	infohtml+='<span class="applyssBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">申请归还</span></div>';
			        }else if(val.power==1&&val.states==6){
			        	infohtml+='<div class="applysssBtn1">';
			        	infohtml+='<span class="applysssBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">正在处理</span></div>';
			        }else if(val.type==1){
			        	infohtml+='<div class="applysBtn1">';
			        	infohtml+='<span class="applysBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">已预约(点击取消)</span></div>';
			        }else if(val.type==0){
			        	infohtml+='<div class="applyBtn1">';
			        	infohtml+='<span class="applyBtninfo1"><input type="hidden" class="booksid" value="'+val.bid+'">预约</span></div>';
			        }
			        infohtml+='</div></div>';
		        });
		        $(".content").html(infohtml);
		        var info='<div class="clearfloat"></div>';
		        $(".content").append(info);
		        $(".pagination").show();
	        }
	    },
	    ajaxFormatBack: function (data) {
	        data.total = data.totalpage;
	        data.currentPage = data.currentPage;
	    }
	});
})
</script>
<script>
//申请借阅
var bnum;
$(".content").on('click','.applyBtn',function(){
	bnum = $(this).index('.applyBtn');
	// alert(bnum);
	var bookid = $(this).find('input').val();
	// alert(bookid);
	$.ajax({
        type: "POST",
        url: "/index/screendetails/doapply",
        data: {'bookid': bookid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('已申请！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applysBtn">';
                	bhtml += '<span class="applysBtninfo"><input type="hidden" class="bookid" value="'+bookid+'">已申请(点击取消)</span></div>';
                    $(".applyBtn").eq(bnum).replaceWith(bhtml);
                });
            }else{
                layer.msg('申请失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//取消申请
var bnums;
$(".content").on('click','.applysBtn',function(){
	bnums = $(this).index('.applysBtn');
	// alert(bnums);
	var bookid = $(this).find('input').val();
	// alert(bookid);
	$.ajax({
        type: "POST",
        url: "/index/screendetails/cancelapply",
        data: {'bookid': bookid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('取消成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applyBtn">';
                	bhtml += '<span class="applyBtninfo"><input type="hidden" class="bookid" value="'+bookid+'">申请借阅</span></div>';
                    $(".applysBtn").eq(bnums).replaceWith(bhtml);
                });
            }else{
                layer.msg('取消失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//预约书籍
var wantnum;
$(".content").on('click','.applyBtn1',function(){
	wantnum = $(this).index('.applyBtn1');
	// alert(wantnum);
	var booksid = $(this).find('input').val();
	$.ajax({
        type: "POST",
        url: "/index/screendetails/doapplys",
        data: {'bookid': booksid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('预约成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applysBtn1">';
                	bhtml += '<span class="applysBtninfo1"><input type="hidden" class="booksid" value="'+booksid+'">已预约(点击取消)</span></div>';
                    $(".applyBtn1").eq(wantnum).replaceWith(bhtml);
                });
            }else{
                layer.msg('预约失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//取消预约
var wantnums;
$(".content").on('click','.applysBtn1',function(){
	wantnums = $(this).index('.applysBtn1');
	var booksid = $(this).find('input').val();
	$.ajax({
        type: "POST",
        url: "/index/screendetails/cancelapplys",
        data: {'bookid': booksid},
        dataType: "json",
        timeout: 3000,
        success: function (data) {
            console.log(data)
            if(data==1){
                layer.msg('取消成功！', {
                    icon: 1,
                    time: 1000
                }, function () {
                	var bhtml = '';
                	bhtml += '<div class="applyBtn1">';
                	bhtml += '<span class="applyBtninfo1"><input type="hidden" class="booksid" value="'+booksid+'">预约</span></div>';
                    $(".applysBtn1").eq(wantnums).replaceWith(bhtml);
                });
            }else{
                layer.msg('取消失败！', {
                    icon: 2,
                    time: 1000
                });  
            }
        }
    });
})
//归还申请
var applyNum;
$('.content').on('click','.applyssBtn1',function(){
	applyNum = $(this).index('.applyssBtn1');
	var id = $(this).find('input').val();
	// alert(id);
	$.ajax({
	    type: "POST",
	    url: "/index/screendetails/applyrollback",
	    data: {'id': id},
	    dataType: "json",
	    timeout: 3000,
	    success: function (data) {
	        console.log(data)
	        if(data>=1){
	            layer.msg('申请已提交，请等待处理！', {
	                icon: 1,
	                time: 1000
	            }, function () {
	                var bhtml = '';
                	bhtml += '<div class="applysssBtn1">';
                	bhtml += '<span class="applysssBtninfo1"><input type="hidden" class="booksid" value="'+id+'">正在处理</span></div>';
                    $(".applyssBtn1").eq(applyNum).replaceWith(bhtml);
	            });
	        }else{
	            layer.msg('申请失败！', {
                    icon: 2,
                    time: 1000
                }); 
	       	}
	    }
    });
});
</script>
</html>